package com.xm.zcf.dao.categorySecond.impl;

import com.xm.zcf.action.Base.SessionBase;
import com.xm.zcf.dao.categorySecond.CategorySecondDao;
import com.xm.zcf.domain.categorySecond.Categorysecond;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by Administrator on 2017/3/15.
 */
@Repository
public class CategorySecondDaoImpl extends SessionBase implements CategorySecondDao {
    @Override
    public List findByCid(Integer cid) {
        return getSession().createQuery(
                "from Categorysecond c where c.category.cid=?"
        ).setParameter(0,cid)
         .list();
    }

    @Override
    public List<Categorysecond> findSecondAll() {
        return getSession().createQuery("from Categorysecond ").list();
    }

    @Override
    public void save(Categorysecond model) {
        getSession().save(model);
    }

    @Override
    public Categorysecond findById(int csid) {
        Categorysecond categorysecond=(Categorysecond) getSession().createQuery(
                "from Categorysecond c where c.csid=?"
        ).setParameter(0,csid)
                .uniqueResult();
        return categorysecond;
    }

    @Override
    public void deleteCategory(Categorysecond category) {
        getSession().delete(category);
    }

    @Override
    public void update(Categorysecond categorysecond) {
        getSession().update(categorysecond);
    }
}

